package com.itheima.springboot;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ApplicationController {

    //第一种
    @Value("${name}")
    private String name;
    @Value("${person.age}")
    private Integer age;
    //第二种
    @Autowired
    private Environment environment;
    //第三种
    @Autowired
    private Person person;
    @RequestMapping("/hello")
    public String test(){
        System.out.println(environment.getProperty("name")+environment.getProperty("person.age"));
        System.out.println("--------");
        System.out.println(person.getName()+"-"+person.getAge());
        return "hello springboot!"+name+"-"+age;
    }
}
